struct Array {
private:
	size_t arr_size;
	size_t capacity;
	int * data;

	void swap(Array& a) {
		std::swap(capacity, a.capacity);
		std::swap(arr_size, a.arr_size);
		std::swap(data, a.data);
	}
public:
	explicit Array(size_t size)
		: arr_size(size), capacity(size), data(new int[size]) {}
	Array(const Array& arr) : arr_size(arr.arr_size),
			capacity(arr.capacity), data(new int[capacity]) {
		for (size_t i = 0; i < arr_size; ++i) {
			data[i] = arr.data[i];
		}
	}
	Array& operator= (Array const & arr) {
		Array tmp(arr);
		swap(tmp);
		return *this;
	}
	~Array() {
		delete[] data;
	}
	int get(size_t index) const {
		if (index < arr_size) {
			return data[index];
		}
		return 0;
	}
	void set(size_t index, int value) {
		if (index < arr_size) {
			data[index] = value;
		}
	}
	size_t size() const {
		return arr_size;
	}
	void push_back(int value) {
		if(arr_size >= capacity) {
			Array tmp(arr_size*2);
			tmp.arr_size=arr_size;
			for(size_t i = 0; i < arr_size; ++i) {
				tmp.data[i]=data[i];
			}
			swap(tmp);
		}
		data[arr_size]=value;
		++arr_size;
	}
};
